home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / cmds.fmt / bc.man < prev    next >
Encoding:
Text File  |  1989-02-07  |  4.3 KB  |  199 lines

  1.  
  2.  
  3.  
  4. BC                        User Commands                        BC
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      bc - arbitrary-precision arithmetic language and calculator
  10.  
  11. SSYYNNOOPPSSIISS
  12.      bbcc [ --cc ] [ --ll ] [ file ... ]
  13.  
  14. DDEESSCCRRIIPPTTIIOONN
  15.      _B_c is an interactive processor for a language which resem-
  16.      bles C but provides unlimited precision arithmetic.  It
  17.      takes input from any files given, then reads the standard
  18.      input.  The --ll argument stands for the name of an arbitrary
  19.      precision math library.  The syntax for _b_c programs is as
  20.      follows; L means letter a-z, E means expression, S means
  21.      statement.
  22.  
  23.      Comments
  24.            are enclosed in /* and */.
  25.  
  26.      Names
  27.            simple variables: L
  28.            array elements: L [ E ]
  29.            The words `ibase', `obase', and `scale'
  30.  
  31.      Other operands
  32.            arbitrarily long numbers with optional sign and
  33.            decimal point.
  34.            ( E )
  35.            sqrt ( E )
  36.            length ( E )   number of significant decimal digits
  37.            scale ( E )    number of digits right of decimal point
  38.            L ( E , ... , E )
  39.  
  40.      Operators
  41.            +  -  *  /  %  ^ (% is remainder; ^ is power)
  42.            ++   --         (prefix and postfix; apply to names)
  43.            ==  <=  >=  !=  <  >
  44.            =  +=  -=  *=  /=  %=  ^=
  45.  
  46.      Statements
  47.            E
  48.            { S ; ... ; S }
  49.            if ( E ) S
  50.            while ( E ) S
  51.            for ( E ; E ; E ) S
  52.            null statement
  53.            break
  54.            quit
  55.  
  56.      Function definitions
  57.            define L ( L ,..., L ) {
  58.                 auto L, ... , L
  59.                 S; ... S
  60.  
  61.  
  62.  
  63. Sprite v1.0               July 28, 1987                         1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. BC                        User Commands                        BC
  71.  
  72.  
  73.  
  74.                 return ( E )
  75.            }
  76.  
  77.      Functions in --ll math library
  78.            s(x) sine
  79.            c(x) cosine
  80.            e(x) exponential
  81.            l(x) log
  82.            a(x) arctangent
  83.            j(n,x)    Bessel function
  84.  
  85.      All function arguments are passed by value.
  86.  
  87.      The value of a statement that is an expression is printed
  88.      unless the main operator is an assignment.  Either semi-
  89.      colons or newlines may separate statements.  Assignment to
  90.      _s_c_a_l_e influences the number of digits to be retained on
  91.      arithmetic operations in the manner of _d_c(1).  Assignments
  92.      to _i_b_a_s_e or _o_b_a_s_e set the input and output number radix
  93.      respectively.
  94.  
  95.      The same letter may be used as an array, a function, and a
  96.      simple variable simultaneously.  All variables are global to
  97.      the program.  `Auto' variables are pushed down during func-
  98.      tion calls.  When using arrays as function arguments or
  99.      defining them as automatic variables empty square brackets
  100.      must follow the array name.
  101.  
  102.      For example
  103.  
  104.      scale = 20
  105.      define e(x){
  106.           auto a, b, c, i, s
  107.           a = 1
  108.           b = 1
  109.           s = 1
  110.           for(i=1; 1==1; i++){
  111.                a = a*x
  112.                b = b*i
  113.                c = a/b
  114.                if(c == 0) return(s)
  115.                s = s+c
  116.           }
  117.      }
  118.  
  119.      defines a function to compute an approximate value of the
  120.      exponential function and
  121.  
  122.           for(i=1; i<=10; i++) e(i)
  123.  
  124.      prints approximate values of the exponential function of the
  125.      first ten integers.
  126.  
  127.  
  128.  
  129. Sprite v1.0               July 28, 1987                         2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. BC                        User Commands                        BC
  137.  
  138.  
  139.  
  140.      _B_c is actually a preprocessor for _d_c(1), which it invokes
  141.      automatically, unless the --cc (compile only) option is
  142.      present.  In this case the _d_c input is sent to the standard
  143.      output instead.
  144.  
  145. FFIILLEESS
  146.      /usr/lib/lib.b mathematical library
  147.      dc(1)          desk calculator proper
  148.  
  149. SSEEEE AALLSSOO
  150.      dc(1)
  151.      L. L. Cherry and R. Morris, _B_C - _A_n _a_r_b_i_t_r_a_r_y _p_r_e_c_i_s_i_o_n
  152.      _d_e_s_k-_c_a_l_c_u_l_a_t_o_r _l_a_n_g_u_a_g_e
  153.  
  154. BBUUGGSS
  155.      No &&, ||, or ! operators.
  156.      _F_o_r statement must have all three E's.
  157.      _Q_u_i_t is interpreted when read, not when executed.
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. Sprite v1.0               July 28, 1987                         3
  196.  
  197.  
  198.  
  199.